autowatch=1;
function load(path){
    var rootpath = path.substr(0, path.lastIndexOf('/')) || path;
    var newpath=rootpath+'/build.amxd';
    var headpath=rootpath+'/empty.amxd';
    post(newpath);
   var buildfile = new File(newpath,"write","JSON");
   var readfile = new File(path,"read","JSON");
    var headfile=new File(headpath,"read");

    var bw=this.patcher.getnamed("build_wrapper");
    if(bw.subpatcher()){
        var mainp=bw.subpatcher();
      //  iterdeep(mainp);
    } else{
        error("build_wrapper is empty!");
    }
    buildfile.writebytes(headfile.readbytes(32));
    while(readfile.position<readfile.eof){
        buildfile.writebytes(readfile.readbytes(8));
    }
    buildfile.close();
    readfile.close();
    headfile.close();
}   

function error(msg){
    post("Error: "+msg+"\n");
}

function iterdeep(a){

            var obj=a.firstobject;
            if(obj){
                while(obj!=null){
                    if(obj.subpatcher()) { 
                        post("subpatcher: "+obj.subpatcher().name+" args: "+obj.subpatcher().box.getattr("arguments")+"\n");
                        iterdeep(obj.subpatcher()); 
                    }
                    post("filepath "+obj.filepath+" | varname: "+obj.varname+" | classname: "+obj.maxclass+" | args: ");
                    for(arg in obj.getattr("args")){
                        post(arg);
                    }
                    post("\n");
                    obj=obj.nextobject;
                }
      
            }
        
}